﻿using Abp.Domain.Repositories;
using Abp.ObjectMapping;
using System.Linq;
using Teleware.Newbe.Navigation.Web.Domain.Entities;

namespace Teleware.Newbe.Navigation.Web.AppServices.Impl
{
    internal class InfoTagsService : IInfoTagsService
    {
        private readonly IRepository<InfoTag, string> _tagsRepository;
        private readonly IObjectMapper _objectMapper;

        public InfoTagsService(
            IRepository<InfoTag, string> tagsRepository,
            IObjectMapper objectMapper)
        {
            _tagsRepository = tagsRepository;
            _objectMapper = objectMapper;
        }

        public InfoTagsServiceGetAllOutput GetAll()
        {
            var tags = _objectMapper.Map<SimpleInfoTagDto[]>(_tagsRepository.GetAllList().OrderBy(x => x.OrderNo));
            var re = new InfoTagsServiceGetAllOutput
            {
                Items = tags
            };
            return re;
        }
    }
}
